package com.snr.userhistoryprocessor.pojo;

import java.io.Serializable;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ReadingLog implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6004308239343878863L;
	private int id;
	private int userId;
	private String url;
	private double date;
	private int duration;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getUserId() {
		return userId;
	}
	public void setUserId(int userId) {
		this.userId = userId;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public double getDate() {
		return date;
	}
	public void setDate(double date) {
		this.date = date;
	}
	public int getDuration() {
		return duration;
	}
	public void setDuration(int duration) {
		this.duration = duration;
	}
	@Override
	public String toString() {
		return "ReadingLog [id=" + id + ", userId=" + userId + ", url=" + url
				+ ", date=" + date + ", duration=" + duration + "]";
	}
	public static List<ReadingLog> toReadinglogs(List<ReadingLogNoID> list) {
		// TODO Auto-generated method stub
		List<ReadingLog> list2 = new ArrayList<ReadingLog>();
		Iterator<ReadingLogNoID> iterator = list.iterator();
		while (iterator.hasNext()) {
			ReadingLogNoID readingLogNoID = (ReadingLogNoID) iterator.next();
			ReadingLog readingLog = new ReadingLog();
			readingLog.setDate(readingLogNoID.getDate());
			readingLog.setUserId(Integer.parseInt(readingLogNoID.getUserId()));
			readingLog.setDuration(readingLogNoID.getDuration());
			readingLog.setUrl(readingLogNoID.getUrl());
			list2.add(readingLog);
		}
		return list2;
		
	}
	
}
